package com.lightheart.sphr.xiaobinggan.module.home.ui;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.KeyEvent;
import android.widget.EditText;
import android.widget.TextView;
import com.lightheart.sphr.xiaobinggan.R;

/**
 * https://www.jianshu.com/p/de2c1b6c3803
 */
public class BossActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_boss);
        EditText et_test = findViewById(R.id.et_test);

//        et_test.setOnEditorActionListener(object : TextView.OnEditorActionListener {
//            override fun onEditorAction(v: TextView?, actionId: Int, event: KeyEvent?): Boolean {
//                if (event != null) {
//                    if (event.action == KeyEvent.ACTION_DOWN)
//                        Toast.makeText(this@MainActivity,"我是完成",Toast.LENGTH_SHORT).show()
//                    return true
//                }
//                return false
//            }
//        })
        et_test.setOnEditorActionListener(new TextView.OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) {
                if(keyEvent!=null){
                    if(keyEvent.getAction()==KeyEvent.ACTION_DOWN){
//                        Toast.makeText(this,"我是完成", Toast.LENGTH_SHORT).show();
                     return true;
                    }
                }
                return false;
            }
        });
    }
}